﻿using System;

namespace Monopoly.Domain
{
    public abstract class Box
    {
        private static short Identity = 1;
        private short Id;
        private string Name;

        public Box()
            : this("undefined")
        {
        }

        public Box(string Name)
        {
            this.Id = Identity++;
            this.Name = Name;
        }

        public static void ReinitializeIdentity()
        {
            Identity = 1;
        }

        public string GetName()
        {
            return this.Name;
        }

        /// <summary>
        /// Return the current box colorized if available, default text otherwise
        /// </summary>
        /// <param name="Colorized"><code>true</code> if the Box is known as a Field or has Color attribute</param>
        /// <returns></returns>
        public string GetName(bool Colorized)
        {
            try
            {
                if (Colorized)
                    return this.Name.Colorize(((Field)this).GetColor());
                else
                    return this.Name;
            }
            catch (Exception)
            {
                return this.Name;
            }
        }

        public int GetId()
        {
            return this.Id;
        }
    }
}
